<!-- 全部订单页面1。该页面属于正常的Vue页面，正常书写代码结构，但对于订单列表这种页面来说页面性能不太好， -->
<template>
  <view v-if="shenheStatus == 0" class="page">
    <goods-info :goods="goods"></goods-info>
    <refund-info @submitRefund="submitRefund" :goods="goods"></refund-info>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
import goodsInfo from '../components/order-refund/goods-info.vue';
import refundInfo from '../components/order-refund/refund-info.vue';
export default {
  data() {
    return {
      order_id: 0,
      goods: null,
      template_id: [],
    };
  },
  components: {
    Shenhe,
    goodsInfo,
    refundInfo,
  },
  onLoad(t) {
    uni.setNavigationBarTitle({
      title: this.$t('title.orderRefund'),
    });

    this.order_id = t.id;
    this.goods = uni.getStorageSync("refund-goods")
  },
  watch: {},
  methods: {
    submitRefund(e) {
      var that = this;
      let arr = [];
      this.goods.forEach(item => {
        arr.push(item.order_detail_id);
      });
      if (e.desc == '') {
        uni.showToast({
          title: this.$t('order.fill'),
          icon: 'none',
        });
        return;
      }
      if (arr.length) {
        let data = {
          type: e.type,
          desc: e.desc,
          pic_list: JSON.stringify(e.pic_list),
          order_detail_id: JSON.stringify(arr),
        };
        that.submitRefund1(data);
      }
    },
    submitRefund1(e) {
      this.$allrequest.order.refund(e).then(res => {
        uni.showToast({
          title: res.msg,
          icon: 'none',
          duration: 2000,
        });
        if (res.code == 0) {
          setTimeout(function () {
            uni.navigateBack({
              delta: 1,
            });
          }, 1500);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  display: flex;
  flex-direction: column;
  background-color: #f2f2f2;
  min-height: 100vh;
}
</style>
